package view.component.weapon
{
	import enums.main.UISize;
	
	import feathers.controls.Button;
	import feathers.controls.Label;
	import feathers.controls.ScrollContainer;
	import feathers.controls.TabBar;
	
	import util.FG2FUGenerator;
	
	import view.event.weapon.WeaponSearchViewEvent;
	
	
	/**
	 * 近身武器搜索界面基类
	 * @author £iang
	 * 
	 */	
	public class BaseShortWeaponSearchView extends BaseWeaponSearchView
	{
		//-----------------------------
		// variables
		//-----------------------------
		
		/** 级别标题 */
		public var levelTitle:Label;
		/** 级别选项 */
		public var levelTabBar:TabBar;
		/** 属性标题 */
		public var attributeTitle:Label;
		/** 觉醒选项 */
		public var awakenTabBar:TabBar;
		/** 属性选项 */
		public var attributeTabBar:TabBar;
		/** 属性选项滚动条容器 */
		public var attributeTabSC:ScrollContainer;
		/** 斩味标题 */
		public var sharpTitle:Label;
		/** 匠选项 */
		public var addSharpTabBar:TabBar;
		/** 斩味选项 */
		public var sharpTabBar:TabBar;
		/** 斩味选项滚动条容器 */
		public var sharpTabSC:ScrollContainer;
		/** 洞数标题 */
		public var slotTitle:Label;
		/** 洞数选项 */
		public var slotTabBar:TabBar;
		/** 洞数选项滚动条容器 */
		public var slotTabSC:ScrollContainer;
		/** 结果排序标题 */
		public var sortTitle:Label;
		/** 结果排序选项 */
		public var sortTabBar:TabBar;
		/** 结果排序选项滚动条容器 */
		public var sortTabSC:ScrollContainer;
		
		//-----------------------------
		// properties
		//-----------------------------
		
		//-----------------------------
		// setter&getter
		//-----------------------------
		
		//-----------------------------
		// methods
		//-----------------------------
		
		/**
		 * 初始化函数 
		 * 
		 */		
		override protected function initialize():void
		{
			super.initialize();
			
			var labelVec:Vector.<String> = new Vector.<String>();
		
			levelTitle = new Label();
			levelTitle.text = "级别：";
			mainSC.addChild( levelTitle );
			
			labelVec.push( "下位", "上位" );
			levelTabBar = createTabBar( labelVec );
			mainSC.addChild( levelTabBar );
			
			attributeTitle = new Label();
			attributeTitle.text = "属性：";
			mainSC.addChild( attributeTitle );
			
			labelVec.length = 0;
			labelVec.push( "全部", "非觉醒", "觉醒" );
			awakenTabBar = createTabBar( labelVec );
			mainSC.addChild( awakenTabBar );
			
			labelVec.length = 0;
			labelVec.push( "全部", "无", "火", "水", "雷", "冰", "龙", "毒", "麻", "眠", "爆" );
			attributeTabBar = createTabBar( labelVec );
			attributeTabSC = new ScrollContainer();
			mainSC.addChild( attributeTabSC );
			attributeTabSC.addChild( attributeTabBar );
			
			sharpTitle = new Label();
			sharpTitle.text = "斩味：";
			mainSC.addChild( sharpTitle );
			
			labelVec.length = 0;
			labelVec.push( "全部", "匠前", "匠后" );
			addSharpTabBar = createTabBar( labelVec );
			mainSC.addChild( addSharpTabBar );
			
			labelVec.length = 0;
			labelVec.push( "全部", "红", "橙", "黄", "绿", "蓝", "白", "紫" );
			sharpTabBar = createTabBar( labelVec );
			sharpTabSC = new ScrollContainer();
			mainSC.addChild( sharpTabSC );
			sharpTabSC.addChild( sharpTabBar );
			
			slotTitle = new Label();
			slotTitle.text = "洞数：";
			mainSC.addChild( slotTitle );
			
			labelVec.length = 0;
			labelVec.push( "全部", "0洞", "1洞", "2洞", "3洞" );
			slotTabBar = createTabBar( labelVec );
			slotTabSC = new ScrollContainer();
			mainSC.addChild( slotTabSC );
			slotTabSC.addChild( slotTabBar );
			
			sortTitle = new Label();
			sortTitle.text = "排序：";
			mainSC.addChild( sortTitle );
			
			labelVec.length = 0;
			labelVec.push( "攻击力", "属性值", "斩味值", "会心", "洞数" );
			sortTabBar = createTabBar( labelVec );
			sortTabSC = new ScrollContainer();
			mainSC.addChild( sortTabSC );
			sortTabSC.addChild( sortTabBar );
			
			
		}
		
		/**
		 * 绘制函数 
		 * 
		 */		
		override protected function draw():void
		{		
			super.draw();
			levelTitle.x = 20 * this.dpiScale;
			levelTabBar.x = 110 * this.dpiScale;
			attributeTitle.x = 20 * this.dpiScale;
			attributeTitle.y = 60 * this.dpiScale;
			awakenTabBar.x =  110 * this.dpiScale;
			awakenTabBar.y =  60 * this.dpiScale;
			attributeTabSC.x = 110 * this.dpiScale;
			attributeTabSC.y = 120 * this.dpiScale;
			attributeTabSC.width = UISize.MAIN_W - 130 * this.dpiScale;
			sharpTitle.x = 20 * this.dpiScale;
			sharpTitle.y = 180 * this.dpiScale;
			addSharpTabBar.x =  110 * this.dpiScale;
			addSharpTabBar.y =  180 * this.dpiScale;
			sharpTabSC.x = 110 * this.dpiScale;
			sharpTabSC.y = 240 * this.dpiScale;
			sharpTabSC.width = UISize.MAIN_W - 130 * this.dpiScale;
			slotTitle.x = 20 * this.dpiScale;
			slotTitle.y = 300 * this.dpiScale;
			slotTabSC.x =  110 * this.dpiScale;
			slotTabSC.y =  300 * this.dpiScale;
			slotTabSC.width = UISize.MAIN_W - 130 * this.dpiScale;
		
			sortTabSC.y = ( 360 + insertOffset ) * this.dpiScale;
			sortTabSC.width = UISize.MAIN_W - 130 * this.dpiScale;
			sortTitle.x = 20 * this.dpiScale;
			sortTitle.y = ( 360 + insertOffset ) * this.dpiScale;
			sortTabSC.x = 110 * this.dpiScale;
		}
		 
		override public function dispatchSearchEvent():void
		{
			var weaponSearchEvent:WeaponSearchViewEvent = 
				new WeaponSearchViewEvent( WeaponSearchViewEvent.SEARCH );
			
			weaponSearchEvent.rank = levelTabBar.selectedIndex + 1;
			weaponSearchEvent.awakeType = awakenTabBar.selectedIndex;
			weaponSearchEvent.attribute = attributeTabBar.selectedIndex - 1;
			weaponSearchEvent.add = addSharpTabBar.selectedIndex;
			weaponSearchEvent.blade = sharpTabBar.selectedIndex;
			weaponSearchEvent.slot = slotTabBar.selectedIndex - 1;
			weaponSearchEvent.sort = sortTabBar.selectedIndex;
			dispatchCommonEvent( weaponSearchEvent );
		}
		
		//-----------------------------
		// events
		//-----------------------------
	
		//-----------------------------
		// dispose
		//-----------------------------
		
		/**
		 * 析构函数 
		 * 
		 */		
		override public function dispose():void
		{
			levelTitle.dispose(); levelTitle = null;
			
			var button:Button;
			var k:int;
			
			for ( k = 0; k < levelTabBar.numChildren; k ++ )
			{
				if ( levelTabBar.getChildAt( k ) is Button )
				{
					button = levelTabBar.getChildAt( k ) as Button;
					button.dispose();
					FG2FUGenerator.deepDisposeButtonComp( button );
					button = null;
				}
			}
			
			levelTabBar.dispose(); levelTabBar = null;
			attributeTitle.dispose(); attributeTitle = null;
			
			for ( k = 0; k < awakenTabBar.numChildren; k ++ )
			{
				if ( awakenTabBar.getChildAt( k ) is Button )
				{
					button = awakenTabBar.getChildAt( k ) as Button;
					button.dispose();
					FG2FUGenerator.deepDisposeButtonComp( button );
					button = null;
				}
			}
			
			awakenTabBar.dispose(); awakenTabBar = null;
			
			for ( k = 0; k < attributeTabBar.numChildren; k ++ )
			{
				if ( attributeTabBar.getChildAt( k ) is Button )
				{
					button = attributeTabBar.getChildAt( k ) as Button;
					button.dispose();
					FG2FUGenerator.deepDisposeButtonComp( button );
					button = null;
				}
			}
			
			attributeTabSC.dispose(); attributeTabSC = null;
			sharpTitle.dispose(); sharpTitle = null;
			
			for ( k = 0; k < addSharpTabBar.numChildren; k ++ )
			{
				if ( addSharpTabBar.getChildAt( k ) is Button )
				{
					button = addSharpTabBar.getChildAt( k ) as Button;
					button.dispose();
					FG2FUGenerator.deepDisposeButtonComp( button );
					button = null;
				}
			}
			
			addSharpTabBar.dispose(); addSharpTabBar = null;
			
			for ( k = 0; k < sharpTabBar.numChildren; k ++ )
			{
				if ( sharpTabBar.getChildAt( k ) is Button )
				{
					button = sharpTabBar.getChildAt( k ) as Button;
					button.dispose();
					FG2FUGenerator.deepDisposeButtonComp( button );
					button = null;
				}
			}
			
			sharpTabSC.dispose(); sharpTabSC = null;
			slotTitle.dispose(); slotTitle = null;
			
			for ( k = 0; k < slotTabBar.numChildren; k ++ )
			{
				if ( slotTabBar.getChildAt( k ) is Button )
				{
					button = slotTabBar.getChildAt( k ) as Button;
					button.dispose();
					FG2FUGenerator.deepDisposeButtonComp( button );
					button = null;
				}
			}
			
			slotTabSC.dispose(); slotTabSC = null;
			sortTitle.dispose(); sortTitle = null;
			
			for ( k = 0; k < sortTabBar.numChildren; k ++ )
			{
				if ( sortTabBar.getChildAt( k ) is Button )
				{
					button = sortTabBar.getChildAt( k ) as Button;
					button.dispose();
					FG2FUGenerator.deepDisposeButtonComp( button );
					button = null;
				}
			}
			
			sortTabSC.dispose(); sortTabSC = null;
			super.dispose();
		}
		
		//-----------------------------
		// construction
		//-----------------------------
		
		/**
		 * 构造函数
		 *
		 */
		public function BaseShortWeaponSearchView()
		{
			super();
		}
	}
}